//思路：第一种转化为StringBuilder操作还是会出现超时，我们可以对其先进行映射


import javax.management.remote.rmi._RMIConnection_Stub;
import java.util.*;

public class Solution {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int len = in.nextInt();
        int m = in.nextInt();
        StringBuilder s=new StringBuilder(in.next());
        for (int i = 0; i < m; i++) {
            int op = in.nextInt();
            char c1 = in.next().charAt(0);
            char c2 = in.next().charAt(0);
            if(op==1){
                for (int j = 0; j < s.length(); j++) {
                    if(s.charAt(j)>=c1&&s.charAt(j)<=c2) s.setCharAt(j,((char) (s.charAt(j)+(int)('A'-'a'))));
                }
            }else{
                for (int j = 0; j < s.length(); j++) {
                    if(s.charAt(j)>=c1&&s.charAt(j)<=c2) s.setCharAt(j,((char) (s.charAt(j)-(int)('A'-'a'))));

                }
            }
        }
        System.out.println(new String(s));

    }

}














